import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);
// 登录验证
export default new Vuex.Store({
  state: {
    user: false,
    openID: "oGu4K5EckhQz2Dt_5Qfo3yz4lkfM", //此openid是可以使用管理后台人的的openid
    userInfo: ""
  },
  mutations: {
    // 登录
    login(state, user) {
      state.user = user;
      localStorage.setItem("userInfo", user);
    },
    // 退出
    logout(state, user) {
      state.user = "";
      localStorage.clear();
    },
    // 设置用户信息
    setUserInfo(state, user) {
      state.userInfo = user;
      localStorage.setItem("info", JSON.stringify(user));
      console.log('localStorage.setItem("info"');
    }
  }
});
